package com.extra_archive.framework.core.mvc.view 
{
	import com.extra_archive.framework.core.mvc.controller.IController;
	import com.extra_archive.framework.core.mvc.model.IModel;
	import com.extra_archive.framework.utils.ArrayUtils;

	import flash.events.Event;

	public class CompositeView extends ComponentView {
		private var _children : Array;
		
		public function CompositeView(model : IModel = null, controller : IController = null) {
			super(model, controller);
			
			_children=new Array();
		}
		
		
		override public function addComponent(component : IComponentView) : void {
			_children.push(component);
		}

		override public function removeComponent(component : IComponentView) : void {
			ArrayUtils.removeElement(_children, component);
		}

		override public function update(event : Event = null) : void {
			for each(var component:IComponentView in _children){
				component.update();
			}
		}
		
		override public function getChild(index : int) : ComponentView {
			return this.getChildAt(index) as ComponentView;
		}
	}
}
